package threadmethodcall;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

/**
 * @description:
 * @author: jhy
 * @time: 2021/4/12 19:42
 */

//Thread.join()：等待当前线程死亡，只有当前线程死亡了，才能继续执行下面的代码
public class JoinMethodUseDemo {

    public static void main(String[] args) {

        Thread threadA = new Thread(() -> {
            System.out.println("A线程执行了");
        }, "A");

        Thread threadB = new Thread(() -> {
            try {
                //等待threadA线程死亡
                threadA.join();
            } catch (InterruptedException exception) {
                exception.printStackTrace();
            }
            System.out.println("B线程执行了");
        }, "B");

        Thread threadC = new Thread(() -> {
            try {
                //等待threadB线程死亡
                threadB.join();
            } catch (InterruptedException exception) {
                exception.printStackTrace();
            }
            System.out.println("C线程执行了");
        }, "c");

        threadA.start();
        threadB.start();
        threadC.start();
    }
}
